# 导入包
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
# 1.导入键盘操作类
from selenium.webdriver.common.keys import Keys
# 获取浏览器驱动
driver = webdriver.Firefox()
driver.maximize_window()
# 打开测试的页面
url = 'file:///root/NSD2408/html/registerA.html'
driver.get(url)

# 输入用户名admin1
username = driver.find_element(By.CSS_SELECTOR, '#userA')
username.send_keys('admin1')
sleep(3)
# 在用户名文本框中执行退格键
username.send_keys(Keys.BACKSPACE)
sleep(3)
# 在用户名位置执行ctrl+a
username.send_keys(Keys.CONTROL, 'a')
# 在用户名上执行ctrl+c，在密码框位置执行ctrl+v
username.send_keys(Keys.CONTROL, 'c')
sleep(3)
password = driver.find_element(By.CSS_SELECTOR, '#passwordA')
password.send_keys(Keys.CONTROL, 'v')
sleep(3)
# 在按钮上执行回车键
button = driver.find_element(By.CSS_SELECTOR, '[type="submitA"]')
button.send_keys(Keys.ENTER)
# 关闭浏览器
sleep(3)
driver.quit()